﻿using Learun.Util;
using SqlSugar;
using System;
using System.Collections.Generic;
namespace Learun.Application.TwoDevelopment.ZZDT_EC

{
    /// <summary>
    /// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
    /// Copyright (c) 2013-2018 Hexagon PPM
    /// 创 建：超级管理员
    /// 日 期：2022-06-21 15:32
    /// 描 述：接线模块 - 通道
    /// </summary>
    [SugarTable(TableName = "ec_Panel_Channel")]
    public class ec_PanelChannelEntity
    {
        public ec_PanelChannelEntity()
        {
            lock_flg = 0;//默认0
        }
        #region 实体成员
        /// <summary>
        /// StripID
        /// </summary>
        /// <returns></returns>
        public string StripID { get; set; } = "";
        /// <summary>
        /// PanelID
        /// </summary>
        /// <returns></returns>
        //public string PanelID { get; set; } = "";

        /// <summary>
        /// ID
        /// </summary>
        /// <returns></returns>
        [SugarColumn(IsPrimaryKey = true)]
        public string ChannelID { get; set; }
        /// <summary>
        /// 通道名字
        /// </summary>
        /// <returns></returns>
        public string ChannelName { get; set; } = "";

        /// <summary>
        /// IO
        /// </summary>
        public string IO_TYPE { get; set; } = "";
        /// <summary>
        /// 锁定（0 1）
        /// </summary>
        /// <returns></returns>
        public int lock_flg { get; set; }

        /// <summary>
        /// 顺序
        /// </summary>
        /// <returns></returns>
        public int? Channel_Seq { get; set; }

        /// <summary>
        /// 伪分组名称
        /// </summary>
        /// <returns></returns>
        public string FakeGroupName { get; set; } = "";
        /// <summary>
        /// 伪分组描述
        /// </summary>
        /// <returns></returns>
        public string FakeGroupDesc { get; set; } = "";
        /// <summary>
        /// 伪分组描述（英文）
        /// </summary>
        /// <returns></returns>
        public string FakeGroupDescEN { get; set; } = "";
        /// <summary>
        /// 伪信号类型
        /// </summary>
        /// <returns></returns>
        public string FakeSignalType { get; set; } = "";

        /// <summary>
        /// 如果是母线，则直接体现在通道上
        /// </summary>
        /// <returns></returns>
        public string HomerunCableId { get; set; } = "";

        /// <summary>
        /// 创建人
        /// </summary>
        /// <returns></returns>
        public string CreateUserID { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        /// <returns></returns>
        public DateTime? CreateTime { get; set; }
        /// <summary>
        /// 更新人
        /// </summary>
        /// <returns></returns>
        public string UpdateUserID { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        /// <returns></returns>
        public DateTime? UpdateTime { get; set; }
        #endregion

        #region 扩展操作
        /// <summary>
        /// 新增调用
        /// </summary>
        public void Create()
        {
            this.ChannelID = Guid.NewGuid().ToString();
            this.CreateTime = Time.MySqlTime;
            UserInfo userInfo = LoginUserInfo.Get();
            this.CreateUserID = userInfo.userId;


        }
        /// <summary>
        /// 编辑调用
        /// </summary>
        /// <param name="keyValue"></param>
        public void Modify(string keyValue)
        {
            this.ChannelID = keyValue;
            this.UpdateTime = Time.MySqlTime;
            UserInfo userInfo = LoginUserInfo.Get();
            this.UpdateUserID = userInfo.userId;
        }
        #endregion

        #region 扩展字段
        /// <summary>
        /// 方便批量创建时，从http里获取
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<ec_PanelStripTermEntity> Terms { set; get; }

        [SugarColumn(IsIgnore = true)]
        public ec_Wire_GroupEntity Signal { set; get; }


        /// <summary>
        /// 如果是母线，则直接体现在通道上
        /// </summary>
        /// <returns></returns>
        [SugarColumn(IsIgnore = true)]
        public string HomerunCableName { get; set; } = "";
        /// <summary>
        /// true时，表示假的。真正的结构还是panel strip term
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        bool fakeFlg { get; set; } = false;
        #endregion
    }
}

